package orchestration.businessprocess.model;

import orchestration.businessprocess.execution.Property;
import orchestration.businessprocess.model.nodes.BPNode;


/**
 * 
 * A description of some type of data that will be used as input or output for {@link BPNode}
 * @author  <a href="mailto:car.ferrarini@gmail.com">Carlo Ferrarini</a>
 */
public class BPArtifact{

	/**
	 * @uml.property  name="id"
	 * @uml.associationEnd  
	 */
	private BPArtifactId id;
	/**
	 * @uml.property  name="name"
	 */
	private String name;
	/**
	 * @uml.property  name="type"
	 */
	private Class<?> type;
	/**
	 * @uml.property  name="componentType"
	 */
	private Class<?> componentType;
	
	public BPArtifact(BPArtifactId id, String name, Class<?> type) {
		super();
		this.id = id;
		this.name = name;
		this.type = type;
	}
	public BPArtifact(BPArtifactId id, String name, Class<?> type,Class<?> componentType) {
		super();
		this.id = id;
		this.name = name;
		this.type = type;
		this.componentType=componentType;
	}
	public BPArtifact(BPArtifactId id) {
		super();
		this.id = id;
	}
	/**
	 * @return
	 * @uml.property  name="id"
	 */
	public BPArtifactId getId() {
		return id;
	}
	
	/**
	 * @return
	 * @uml.property  name="name"
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name
	 * @uml.property  name="name"
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return
	 * @uml.property  name="type"
	 */
	public Class<?> getType() {
		return type;
	}
	/**
	 * @return
	 * @uml.property  name="componentType"
	 */
	public Class<?> getComponentType() {
		return componentType;
	}
	public Property createProperty(){
		return new Property(this);
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BPArtifact other = (BPArtifact) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}	
}
